﻿using System.Collections.Generic;
using System.Net;

namespace CommonUtils
{
    //resources/ip-division.txt
    public class IpDivision
    {
        public string Start;
        public string End;
        public string Belong;

        public string[] GetIps()
        {
            IPAddress endIp = null;
            var currentIp = IPAddress.TryParse(Start, out var startIp);
            currentIp = currentIp && IPAddress.TryParse(End, out endIp);
            var ips = new List<string>();
            if (currentIp)
                for (var ipValue = startIp.GetAddressBytes().Value() + 1; ipValue < endIp.GetAddressBytes().Value(); ipValue++)
                    ips.Add(new IPAddress(ipValue.Bytes()).ToString());
            return ips.ToArray();
        }
    }
}
